/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Entidades;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author ivana
 */
@Entity
@Table(name = "transporte")
@NamedQueries({
    @NamedQuery(name = "Transporte.findAll", query = "SELECT t FROM Transporte t"),
    @NamedQuery(name = "Transporte.findByIdTransporte", query = "SELECT t FROM Transporte t WHERE t.idTransporte = :idTransporte"),
    @NamedQuery(name = "Transporte.findByPatenteTransporte", query = "SELECT t FROM Transporte t WHERE t.patenteTransporte = :patenteTransporte"),
    @NamedQuery(name = "Transporte.findByTaraTransporte", query = "SELECT t FROM Transporte t WHERE t.taraTransporte = :taraTransporte"),
    @NamedQuery(name = "Transporte.findByAcoplado", query = "SELECT t FROM Transporte t WHERE t.acoplado = :acoplado"),
    @NamedQuery(name = "Transporte.findByTaraAcoplado", query = "SELECT t FROM Transporte t WHERE t.taraAcoplado = :taraAcoplado")})
public class Transporte implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idTransporte")
    private Integer idTransporte;
    @Basic(optional = false)
    @Column(name = "patenteTransporte")
    private String patenteTransporte;
    @Basic(optional = false)
    @Column(name = "taraTransporte")
    private float taraTransporte;
    @Basic(optional = false)
    @Column(name = "acoplado")
    private int acoplado;
    @Column(name = "taraAcoplado")
    private Float taraAcoplado;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "transporte")
    private Collection<Transportetransportista> transportetransportistaCollection;
    @JoinColumn(name = "idEstadoEspera", referencedColumnName = "idEstadoEspera")
    @ManyToOne(optional = false)
    private Estadoespera estadoespera;
    @JoinColumn(name = "idmodelo", referencedColumnName = "idmodelo")
    @ManyToOne(optional = false)
    private Modelo modelo;
    @JoinColumn(name = "idmarca", referencedColumnName = "idmarca")
    @ManyToOne(optional = false)
    private Marca marca;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "transporte")
    private Collection<Cargaempaque> cargaempaqueCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "transporte")
    private Collection<Remito> remitoCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "transporte")
    private Collection<Recepcion> recepcionCollection;

    public Transporte() {
    }

    public Transporte(Integer idTransporte) {
        this.idTransporte = idTransporte;
    }

    public Transporte(Integer idTransporte, String patenteTransporte, float taraTransporte, int acoplado) {
        this.idTransporte = idTransporte;
        this.patenteTransporte = patenteTransporte;
        this.taraTransporte = taraTransporte;
        this.acoplado = acoplado;
    }

    public Integer getIdTransporte() {
        return idTransporte;
    }

    public void setIdTransporte(Integer idTransporte) {
        Integer oldIdTransporte = this.idTransporte;
        this.idTransporte = idTransporte;
        changeSupport.firePropertyChange("idTransporte", oldIdTransporte, idTransporte);
    }

    public String getPatenteTransporte() {
        return patenteTransporte;
    }

    public void setPatenteTransporte(String patenteTransporte) {
        String oldPatenteTransporte = this.patenteTransporte;
        this.patenteTransporte = patenteTransporte;
        changeSupport.firePropertyChange("patenteTransporte", oldPatenteTransporte, patenteTransporte);
    }

    public float getTaraTransporte() {
        return taraTransporte;
    }

    public void setTaraTransporte(float taraTransporte) {
        float oldTaraTransporte = this.taraTransporte;
        this.taraTransporte = taraTransporte;
        changeSupport.firePropertyChange("taraTransporte", oldTaraTransporte, taraTransporte);
    }

    public int getAcoplado() {
        return acoplado;
    }

    public void setAcoplado(int acoplado) {
        int oldAcoplado = this.acoplado;
        this.acoplado = acoplado;
        changeSupport.firePropertyChange("acoplado", oldAcoplado, acoplado);
    }

    public Float getTaraAcoplado() {
        return taraAcoplado;
    }

    public void setTaraAcoplado(Float taraAcoplado) {
        Float oldTaraAcoplado = this.taraAcoplado;
        this.taraAcoplado = taraAcoplado;
        changeSupport.firePropertyChange("taraAcoplado", oldTaraAcoplado, taraAcoplado);
    }

    public Collection<Transportetransportista> getTransportetransportistaCollection() {
        return transportetransportistaCollection;
    }

    public void setTransportetransportistaCollection(Collection<Transportetransportista> transportetransportistaCollection) {
        this.transportetransportistaCollection = transportetransportistaCollection;
    }

    public Estadoespera getEstadoespera() {
        return estadoespera;
    }

    public void setEstadoespera(Estadoespera estadoespera) {
        Estadoespera oldEstadoespera = this.estadoespera;
        this.estadoespera = estadoespera;
        changeSupport.firePropertyChange("estadoespera", oldEstadoespera, estadoespera);
    }

    public Modelo getModelo() {
        return modelo;
    }

    public void setModelo(Modelo modelo) {
        Modelo oldModelo = this.modelo;
        this.modelo = modelo;
        changeSupport.firePropertyChange("modelo", oldModelo, modelo);
    }

    public Marca getMarca() {
        return marca;
    }

    public void setMarca(Marca marca) {
        Marca oldMarca = this.marca;
        this.marca = marca;
        changeSupport.firePropertyChange("marca", oldMarca, marca);
    }

    public Collection<Cargaempaque> getCargaempaqueCollection() {
        return cargaempaqueCollection;
    }

    public void setCargaempaqueCollection(Collection<Cargaempaque> cargaempaqueCollection) {
        this.cargaempaqueCollection = cargaempaqueCollection;
    }

    public Collection<Remito> getRemitoCollection() {
        return remitoCollection;
    }

    public void setRemitoCollection(Collection<Remito> remitoCollection) {
        this.remitoCollection = remitoCollection;
    }

    public Collection<Recepcion> getRecepcionCollection() {
        return recepcionCollection;
    }

    public void setRecepcionCollection(Collection<Recepcion> recepcionCollection) {
        this.recepcionCollection = recepcionCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idTransporte != null ? idTransporte.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Transporte)) {
            return false;
        }
        Transporte other = (Transporte) object;
        if ((this.idTransporte == null && other.idTransporte != null) || (this.idTransporte != null && !this.idTransporte.equals(other.idTransporte))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entidades.Transporte[idTransporte=" + idTransporte + "]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }

}
